<extend name="Base:main" />
<block name="title">
<title>蔬菜外卖 - 菜品统计</title>
</block>
<block name="main-content">
<div class="row">
	<div class="box col-md-12">
		<div class="box-inner">
			<div class="box-header well" data-original-title="">
				<h2>
					<i class="glyphicon glyphicon-user"></i>配送区域管理
				</h2>

				<div class="box-icon">
					<a href="#" class="btn btn-add btn-round btn-default"><i
						class="glyphicon glyphicon-plus"></i></a> <a href="#"
						class="btn btn-minimize btn-round btn-default"><i
						class="glyphicon glyphicon-chevron-up"></i></a> <a href="#"
						class="btn btn-close btn-round btn-default"><i
						class="glyphicon glyphicon-remove"></i></a>
				</div>
			</div>
			<div class="box-content">
				<div class="alert alert-info">对配送区域进行查看以及管理</div>
				<div class="row">
					<div class="col-xs-4 form-group">
						<label for="cdate">日期：</label> <input type="date"
							class="form-control" id="cdate"
							onchange="javascript:getSummary();" />
					</div>
					<div class="col-xs-4 form-group">
						<label for="area">区域：</label> <select class="form-control"
							id="area" onchange="javascript:getSummary();">
							<option value="">全部</option>
							<foreach name="areas" item="area">
							<option value="{$area.area_name}">{$area.area_name}</option>
							</foreach>
						</select>
					</div>
					<div class="col-xs-4 form-group">
						<label for="ptime">时间段：</label> <select class="form-control"
							id="ptime" onchange="javascript:getSummary();">
							<option value="">全部</option>
							<foreach name="ptimes" item="ptime">
							<option value="{$ptime}">{$ptime}</option>
							</foreach>
						</select>
					</div>
				</div>
				<table
					class="table table-striped table-bordered bootstrap-datatable datatable responsive">
					<thead>
						<tr>
							<th>序号</th>
							<th>菜品名</th>
							<th>菜品数量</th>
							<th>菜品类型</th>
							<th>菜品标签</th>
						</tr>
					</thead>
					<tbody id="tbody">
						<foreach name="list" item="v">
						<tr>
							<td>{++$i}</a></td>
							<td>{$v.food_name}<small>({$v.category})</small></td>
							<td>{$v.num}{$v.unit}</td>
							<td>{$v.type}</td>
							<td>{$v.food_tag}</td>
						</tr>
						</foreach>
					</tbody>
					<tfoot>
						<tr>
							<th style="visibility: hidden;">序号</th>
							<th style="visibility: hidden;">菜品名</th>
							<th style="visibility: hidden;">菜品数量</th>
							<th>菜品类型</th>
							<th>菜品标签</th>
						</tr>
					</tfoot>
				</table>
			</div>
			<!-- end box-content -->
		</div>
		<!-- end box-inner -->
	</div>
	<!-- end box -->
</div>
<!-- end row --> </block>
<block name="js-content"> <!-- 日期js --> <script type="text/javascript">
  var getSummaryUrl = "__APP__/Admin/Order/summary";
  $(function(){
	  var date = "<?php echo date('Y-m-d'); ?>";
      $('#cdate').val(date);
//       $('#startTime').datetimepicker({lang:'ch'});
//       $('#startTime').datetimepicker({
//         timepicker:false,
//         format:'Y-m-d'
//       });
  });
  function getSummary(){
	  var area = $("#area").val();
	  var cdate = $("#cdate").val();
	  var ptime = $("#ptime").val();

      table.rows().remove();
      $.post(getSummaryUrl,{area:area,cdate:cdate,ptime:ptime},function(data){
          	//console.log(data);
          	var count = data.length;
          	itmes = new Array(count);
          	for(i=0;i<count;i++){
              	var od = data[i];
          		itmes[i] = [(i+1),od['food_name'],od['num']+od['unit'],od['type'],od['food_tag']];
            }
          	table.rows.add(itmes).draw();
      });
  }
  </script> </block>